package admincow.servlet.becerro;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import admincow.dao.BecerroDAO;
import admincow.vo.BecerroVO;

/**
 * Servlet implementation class for Servlet: UsuarioModificarServlet
 * 
 */
public class BecerroModificarServlet extends javax.servlet.http.HttpServlet
		implements javax.servlet.Servlet {
	static final long serialVersionUID = 1L;

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public BecerroModificarServlet() {
		super();
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/*
	 * (non-Java-doc)
	 * 
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
	 *      HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		String a = request.getParameter("RPbecerro");
		int b = Integer.parseInt(request.getParameter("idInseminacion"));
		int c = Integer.parseInt(request.getParameter("idParto"));
		String d = request.getParameter("RPtoro");
		int e = Integer.parseInt(request.getParameter("idraza"));
		String f = request.getParameter("RPvaca");
		String g = request.getParameter("nombre");
		String h = request.getParameter("fech_nac");
		String i = request.getParameter("sexo");
		int j = Integer.parseInt(request.getParameter("registro"));
		String k = request.getParameter("fech_reg");
		String l = request.getParameter("estado");
		
		BecerroVO vo = new BecerroVO();
		vo.setRPbecerro(a);
		vo.setIdinseminacion(b);
		vo.setIdparto(c);
		vo.setRPtoro(d);
		vo.setIdraza(e);
		vo.setRPvaca(f);
		vo.setNombre(g);
		vo.setFech_nac(h);
		vo.setSexo(i);
		vo.setRegistro(j);
		vo.setFech_reg(k);
		vo.setEstado(l);
		
		BecerroDAO dao = new BecerroDAO();
		dao.actualizar(vo);

		RequestDispatcher rd = request
				.getRequestDispatcher("/becerroBuscar.jsp");
		rd.forward(request, response);

	}
}